package dabs.engine.control;

import java.io.Serializable;

import dabs.engine.environment.AcceptsModifier;
import dabs.engine.environment.Modifier;
import dabs.engine.exceptions.ComponentNotFoundException;
import dabs.engine.messaging.Notification;
import dabs.engine.messaging.NotificationHandler;
import dabs.engine.plant.ComponentPart;
import dabs.engine.plant.PowerPlant;

public class OperatorSoftware implements AcceptsModifier, Serializable {
	private static final long serialVersionUID = 1638651205659512640L;
	
	PowerPlant powerPlant;
	NotificationHandler poffice;
	
	public OperatorSoftware(NotificationHandler poffice, PowerPlant pplant) {
		this.powerPlant = pplant;
		this.poffice    = poffice;
	}
	
	public void runCommand(ComponentCommand command) throws ComponentNotFoundException {
		ComponentPart comp = powerPlant.getComponent(command.getDestination());
		if (comp.isDead())
			poffice.handleNotification(new Notification("Operator", comp.getName() + " is dead"));
		else
			comp.runCommand(command);
	}
	
	public void handleModifier(Modifier modifier) {
		// STUB! We don't have software failures... yet :P
	}

}
